package com.androiddev.stoppa;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.androiddev.stoppa.player.Player;

public class MainMenuActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_mainmenu);

		findViewById(R.id.start_button).setOnClickListener(startGameActivity);
	}

	@Override
	protected void onPostCreate(Bundle savedInstanceState) {
		super.onPostCreate(savedInstanceState);
	}

	View.OnClickListener startGameActivity = new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			EditText editText = ((EditText) findViewById(R.id.editTextNamePlayer));
			if (editText.getText().toString().trim().length() < 1) {
				Toast.makeText(getApplicationContext(), R.string.name_required,
						Toast.LENGTH_LONG).show();
			} else {
				// finish();
				Intent intent = new Intent(MainMenuActivity.this,
						GameActivity.class);
				intent.putExtra("Player", new Player(editText.getText()
						.toString()));
				startActivity(intent);
			}
		}
	};


}
